module BlogsHelper
  def feed_heat(feed)
    case 
    when !feed.pubDate_from_items
       "cold"
    when feed.pubDate_from_items >= 7.days.ago
       "hot"
    when feed.pubDate_from_items >= 40.days.ago
       "medium"
    else
       "cold"
    end
  end
  
  def pagination_links_remote(paginator)
    page_options = {:window_size => 20}
    pagination_links_each(paginator, page_options) do |n|
      options = {
        :url => {:action => 'list_items', :params => {:page => n}},
        :update => 'feeds'
      }
      html_options = {:href => url_for(:action => 'list_items', :params => {:page => n})}
      link_to_remote(n.to_s, options, html_options)
    end
  end
  
  
  def update_blog_list(link, params = {}, css_class=nil, selected_tag=nil)
    link_to_remote( "<span class=\"#{selected_tag || "plain"}\">"+link+"</span>", {
                   :url=>{
      :controller=>"blogs",
      :action=>"ajax_list_items", 
      :params=>params},
      :loading=>"Element.show('update_indicator')",
      :complete=>"Element.hide('update_indicator')",
    :asynchronous=>false}, {
          :class=>css_class})
    
  end
end